const moment = require('moment');

class TimeTool {

  getDate(num = 0) {
    let now = new Date().getTime();
    let date = moment(now - (1000 * 60 * 60 * 24 * num)).format('YYYY-MM-DD');
    return date;
  }

  getDays(date) {
    let start = new Date(date).getTime();
    let now = new Date().getTime();
    let days = parseInt((now - start) / (1000 * 60 * 60 * 24));
    return days;
  }

}

module.exports = new TimeTool();